
package assignment4;

import javax.swing.*;
import java.awt.*;

@SuppressWarnings("serial")
public class Car extends JPanel
{
    private int numCars;
    
    public void drawCar(Graphics g, int x, int y, Color c, int n)
    {   super.paintComponent(g);       
        
        numCars = n;
        
        for(int i = 0; i < numCars; i++)
        {   g.setColor(c);
            g.fillRect(x+(i*120), y, 80, 50);
            g.fillRect((x+70)+(i*120), y + 20, 30, 30);
            g.setColor(Color.black);
            g.fillOval((x+10)+(i*120), y + 40, 20, 20);
            g.fillOval((x+70)+(i*120), y + 40, 20, 20);
        }
    }
}